package com.hqyj.springBoot.modules.common.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author yun
 * @date 2021-5-5 11:37
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)//表示这个ImageType类的序列化方式以对象的序列化方式来实现
public enum ImageType {
    //20 100 200 是多少KB
    PROFILE_SMALL("profile_small",10,10,20),
    PROFILE_MIDDLE("profile_middle",100,100,100),
    PROFILE_BIG("profile_big",220,220,200),
    ;

    public String type;
    public int length;
    public int width;
    public int size;

    ImageType(String type, int length, int width, int size) {
        this.type = type;
        this.length = length;
        this.width = width;
        this.size = size;
    }

//    public static void main(String[] args) {
//        for(ImageType imageType : ImageType.values()){
//            System.out.println(imageType.length + imageType.type);
//        }
//    }
public static ImageType getImageTypeByName(String type) {
    for (ImageType imageType : ImageType.values()) {
        if (type.equals(imageType.type)) {
            return imageType;
        }
    }
    return null;
}
}
